/*
 * @Author: ChunLai
 * @Date: 2022-03-30 14:31:14
 * @LastEditTime: 2025-02-07 14:17:39
 * @Description: 是否可以编辑 + 配置全局公共常用保单参数
 * @FilePath: \01.latest-short-insure\src\mixins\edit.js
 */
import { mapGetters } from "vuex";
import { openInWebview } from "@/utils";
export const editMixin = {
  data() {
    return {
      origin: "",
      imgUrlPath: "//wxou.mschn.cn/app_h5/insurepics",
    };
  },
  computed: {
    ...mapGetters({
      workNum: "workNum",
      orderNum: "orderNum",
      instype: "instype",
      proIdCode: "proIdCode",
      mainRiskCode: "mainRiskCode",
      gysEngName: "gysEngName",
      disabledEdit: "insert/forbidAlter",
      underwriteFlag: "insert/underwriteFlag",
    }),
    apiComParams() {
      let res = {
        comCode: "minsheng",
        workNum: this.workNum,
        orderNum: this.orderNum,
        mainRiskCode: this.mainRiskCode,
      };
      if (this.proIdCode) {
        res.productCode = this.proIdCode;
      }
      return res;
    },
    // 产品唯一标识编码（mainRiskCode||productCode）
    proUniCode() {
      let res = this.mainRiskCode;
      if (this.proIdCode) {
        res = this.proIdCode;
      }
      return res;
    },
    rrwebType() {
      let res = "20";
      if (this.$getDataFromUrl("rrweb")) {
        res = this.$getDataFromUrl("rrweb");
      }
      return res;
    },
  },
  created() {
    this.origin = openInWebview();
  },
  methods: {
    forbidChange() {
      this.$baseAlert("该保单已核保,不可修改信息", () => {
        if (["3", "5", "-1"].includes(this.underwriteFlag)) {
          this.$router.push("/billres");
        } else {
          this.$router.push("/billsure");
        }
      });
    },
  },
};

export const insureBtnMixin = {
  computed: {
    ...mapGetters({
      gaoZhiType: "page/gaoZhiType",
    }),
  },
  methods: {
    toInsure() {
      if (this.gaoZhiType == "1") {
        return this.$router.push("/ques");
      }
      this.$router.push("/form");
    },
  },
};
